package com.ghline.caloncabe.model;

import com.ghline.caloncabe.GameView;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;

public class MyProgressBar {
	
	public static int BMP_ROWS = 1;
    public static int BMP_COLUMNS = 35;
//	public static final int BMP_COLUMNS = 6;
    private int x = 0;
    private int y = 0;
    private GameView gameView;
    private Bitmap bmp;
    private int width;
    private int height;
	
	public MyProgressBar(GameView gameView, Bitmap bmp, int x, int y) {
		
		this.setGameView(gameView);
        this.bmp = bmp;
        this.width = this.bmp.getWidth() / BMP_COLUMNS;
        this.height = this.bmp.getHeight() / BMP_ROWS;
        
        this.x = x;
        this.y = y;
	}
	
	private void update() {
		width = gameView.getProgress();
	}

	public void draw(Canvas canvas) {			
		update();
        Rect dst = new Rect(x, y, x + width, y + height);
        canvas.drawBitmap(bmp, null, dst, null);
	}	
	
	public int getWidth() {
		return width;
	}
	public int getHeight() {
		return height;
	}
	public int getX() {
		return x;
	}
	public int getY() {
		return y;
	}
	public Bitmap getBitmap() {
		return bmp;
	}
	public void setBitmap(Bitmap bmp) {
		this.bmp = bmp;
	}
	public GameView getGameView() {
		return gameView;
	}
	public void setGameView(GameView gameView) {
		this.gameView = gameView;
	}

}
